package com.lxkpt.voutil;

import com.lxkpt.bean.Business;
import com.lxkpt.bean.User;
import com.lxkpt.service.UserService;
import com.lxkpt.vo.BusinessVo;

import java.util.ArrayList;
import java.util.List;

public class BusinessVoUtil {

    /**
     * 封装商家和商家认证人
     *
     * @param businessList
     * @param userService
     * @return
     */
    public static List<BusinessVo> getBusinessVo(List<Business> businessList, UserService userService) {
        if (businessList == null || businessList.size() == 0) {
            return null;
        }
        List<BusinessVo> businessVoList = new ArrayList<>();

        for (int i = 0; i < businessList.size(); i++) {
            BusinessVo businessVo = new BusinessVo();
            User user = new User();
            user.setUserId(businessList.get(i).getBnAuthorId());
            User u = userService.selectOneUser(user);
            businessVo.setBnAuthorName(u.getUserName());
            businessVo.setBusiness(businessList.get(i));
            businessVoList.add(businessVo);
        }
        return businessVoList;
    }
}
